/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.herenit.beijing.poc.empi;

import com.herenit.beijing.dh2011.business.empi.IPatientIndexManager;
import com.herenit.beijing.poc.serverfactory.ServerFactory;
import com.herenit.beijing.dh2011.dto.PageObject;
import com.herenit.beijing.dh2011.entity.PatientIndex;
import com.herenit.beijing.poc.empi.view.EmpiListPanel;
import com.herenit.beijing.poc.serverfactory.ServerFactory;
import java.util.ArrayList;
import java.util.List;
import javax.naming.NamingException;
import javax.swing.table.DefaultTableModel;
import org.jdesktop.beansbinding.*;
import org.jdesktop.swingbinding.JTableBinding;
import org.jdesktop.swingbinding.SwingBindings;
import org.netbeans.api.settings.ConvertAsProperties;
import org.openide.awt.ActionID;
import org.openide.awt.ActionReference;
import org.openide.explorer.view.TableView;
import org.openide.util.Exceptions;
import org.openide.util.Lookup;
import org.openide.windows.TopComponent;

@ConvertAsProperties(dtd = "-//com.herenit.beijing.poc.empi//EmpiList//EN",
autostore = false)
@TopComponent.Description(preferredID = "EmpiListTopComponent",
persistenceType = TopComponent.PERSISTENCE_ALWAYS)
@TopComponent.Registration(mode = "editor", openAtStartup = false)
@ActionID(category = "Window", id = "com.herenit.beijing.poc.empi.EmpiListTopComponent")
@ActionReference(path = "Menu/patientIndex", position = 333)
@TopComponent.OpenActionRegistration(displayName = "#CTL_EmpiListAction",
preferredID = "EmpiListTopComponent")
public final class EmpiListTopComponent extends TopComponent {

    private List<PatientIndex> pats = new ArrayList<PatientIndex>();
    private PageObject pageObject = new PageObject();
    private EmpiListPanel empiListPanel;

    public EmpiListTopComponent() throws IllegalArgumentException, IllegalAccessException {

        initComponents();
        empiListPanel = new EmpiListPanel();
        setName(org.openide.util.NbBundle.getMessage(EmpiListTopComponent.class, "CTL_EmpiListTopComponent"));
        setToolTipText(org.openide.util.NbBundle.getMessage(EmpiListTopComponent.class, "HINT_EmpiListTopComponent"));
       
        
//        jTableBinding = SwingBindings.createJTableBinding(AutoBinding.UpdateStrategy.READ_WRITE, pats, jTable1);
//
//        jTableBinding.setEditable(false);
//
//        jTableBinding.addColumnBinding(BeanProperty.create("patientId")).setColumnName("患者标识号");
//
//        jTableBinding.addColumnBinding(BeanProperty.create("name")).setColumnName("姓名");
//
//        jTableBinding.addColumnBinding(BeanProperty.create("sex.conceptName")).setColumnName("性别");
//
//        jTableBinding.addColumnBinding(BeanProperty.create("birthday")).setColumnName("生日");
//
//        jTableBinding.addColumnBinding(BeanProperty.create("nation.conceptName")).setColumnName("民族");
//
//        jTableBinding.addColumnBinding(BeanProperty.create("nationality.conceptName")).setColumnName("国籍");
//
//        jTableBinding.addColumnBinding(BeanProperty.create("marriage.conceptName")).setColumnName("婚姻状况");
//
//        jTableBinding.addColumnBinding(BeanProperty.create("identityId")).setColumnName("身份证号");
//
//        jTableBinding.addColumnBinding(BeanProperty.create("chargeType.conceptName")).setColumnName("费别");
//
//        jTableBinding.bind();
//
//        Binding bind1 = Bindings.createAutoBinding(AutoBinding.UpdateStrategy.READ_WRITE, pageObject, ELProperty.create("${totalPage}"), totalPageLabel, BeanProperty.create("text"));
//
//        Binding bind2 = Bindings.createAutoBinding(AutoBinding.UpdateStrategy.READ_WRITE, pageObject, ELProperty.create("${pageNo}"), pageNoLabel, BeanProperty.create("text"));
//
//        bg1 = new BindingGroup();
//
//        bg1.addBinding(bind2);
//
//        bg1.addBinding(bind1);
//
//        bg1.bind();



        // jTable1.setModel(new TableModelForList<PatientIndex>(pats,haha));
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        setPreferredSize(new java.awt.Dimension(1024, 768));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 417, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 271, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents

    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables


    public void getRemoteResult() {
    }

    @Override
    public void componentOpened() {
    }

    @Override
    public void componentClosed() {
    }

    void writeProperties(java.util.Properties p) {
        p.setProperty("version", "1.0");
    }

    void readProperties(java.util.Properties p) {
        String version = p.getProperty("version");
    }

    public List<PatientIndex> getPats() {
        return pats;
    }

    public void setPats(List<PatientIndex> pats) {
        this.pats = pats;
    }
}
